`ifndef __ISE__

`include "code\source\P2\scrambler.v"
`include "code\source\P2\hamming_encoder.v"
`include "code\source\P2\interleaver.v"

`endif

module channel_encoder(
           input clk,
           input clk2,
           input rst_n,
           input din,
           input din_valid,
           output dout,
           output dout_valid);

wire scambler_dout, scambler_dout_valid;

scrambler Scrambler( // 理论不执行重载，完全重新来
              .clk (clk ),
              .rst_n (rst_n ),
              .seed (7'b0),
              .load (1'b0),
              .din (din ),
              .din_valid (din_valid ),
              .dout (scambler_dout ),
              .dout_valid (scambler_dout_valid )
          );

wire hamming_dout, hamming_dout_valid;

hamming_encoder Hamming_encoder(
                    .clk (clk ),
                    .clk2 (clk2 ),
                    .rst_n (rst_n ),
                    .din (scambler_dout),
                    .din_valid (scambler_dout_valid),
                    .dout (hamming_dout ),
                    .dout_valid (hamming_dout_valid )
                );

interleaver Interleaver(
                .clk2 (clk2 ),
                .rst_n (rst_n ),
                .din (hamming_dout ),
                .din_valid (hamming_dout_valid ),
                .dout (dout ),
                .dout_valid (dout_valid )
            );

endmodule
